<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="wt.org.WTUser"%>
<%@page import="shmged.com.shlcm.fc.CmQueryResult"%>
<%@page import="shmged.com.shlcm.workflow.setparticipant.TpWorkflowHelper"%>
<%@page import="shmged.com.shlcm.fc.CmPersistenceHelper"%>
<%@page import="shmged.com.shlcm.fc.CmQuerySpec"%>
<%@page import="wt.query.SearchCondition"%>
<%@page import="shmged.com.shlcm.objs.persist.CmReimbursementDetailEntry"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="shmged.com.shlcm.utils.CmIBAHelper"%>
<%@page import="wt.doc.WTDocument"%>
<%@page import="wt.fc.ReferenceFactory"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
ReferenceFactory rf=new ReferenceFactory();
String oid=request.getParameter("oid");
WTDocument doc = (WTDocument)rf.getReference(oid).getObject();
CmIBAHelper holder = new CmIBAHelper(doc);

String sum= holder.getIBAValue("Sum");
String amount= holder.getIBAValue("Amount");
String rbType= holder.getIBAValue("RefeBursementType");
String rbState= doc.getLifeCycleState().getDisplay();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String cdate = sdf.format(doc.getCreateTimestamp()); 

CmQuerySpec qs=new CmQuerySpec(CmReimbursementDetailEntry.class);
String newOid=""+doc.getPersistInfo().getObjectIdentifier().getId();
qs.appendWhere(CmReimbursementDetailEntry.CMIDMASTER,SearchCondition.EQUAL,newOid);
CmQueryResult qr=CmPersistenceHelper.manager.find(qs); 
Map<String,Map<String,Object>> signInfos = TpWorkflowHelper.getLastSignInfo(doc) ;
%>

<html>
<head>
<title>费用报销打印</title>
<style type="text/css">
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
</style>
</head>
<body style="font-size: 12px;font-family: '微软雅黑 ','Microsoft YaHei';">
<div  align="center" >
<div style="width: 720px;">
   <table width="100%">
      <!-- 报销单头 -->
      <tr>
      <td>
          <font style="font-weight: bold; font-size: 20px">报销单</font> 
      </td>
      </tr>
      
      <!-- 报销单属性表格 -->
      <tr>
      <td>
        <table border="1px" width="100%" cellpadding="0" cellspacing="0">
          <%if(!"公共费用".equals(rbType)){ %>
          <tr><td width="120px">项目名称:</td><td  colspan="3" align="left"><%=(holder.getIBAValue("ProjectNo")==null)?"": holder.getIBAValue("ProjectNo")%></td></tr>
          <tr><td>项目编号:</td><td  colspan="3" align="left"><%=(holder.getIBAValue("ProjectName")==null)?"": holder.getIBAValue("ProjectName")%></td></tr>
          <%} %>
          <tr><td width="120px">单据号:</td><td align="left"><%=doc.getName() %></td><td>财务周期:</td><td align="left"><%=(holder.getIBAValue("RefeBursementLife")==null)?"":holder.getIBAValue("RefeBursementLife")%></td></tr>
          <tr><td>报销人:</td><td align="left"><%=((WTUser)doc.getCreator().getObject()).getFullName()%></td><td>报销日期:</td><td align="left"><%=cdate %></td></tr>
          <tr><td>单据类型:</td><td align="left"><%=rbType %></td><td>付款方式:</td><td align="left"><%=holder.getIBAValue("PayMethod") %></td></tr>
          <tr><td>报销金额(小写):</td><td align="left"><%=sum %></td><td>发票数:</td><td align="left"><%=(holder.getIBAValue("InvoiceNum")==null)?"0":holder.getIBAValue("InvoiceNum") %>&nbsp;张</td></tr>
          <tr><td>报销金额(大写):</td><td colspan="3" align="left"><%=amount %></td></tr>
        </table>   
      </td>
      </tr>
      
      <!-- 报销单明细表格 -->
      <tr>
      <td>
         <table border="1px" width="100%" cellpadding="0" cellspacing="0">
            <thead style="font-weight: bold;">
              <tr>
                <td width="100px">类型</td><td width="100px">金额</td><td>用途</td><td width="100px">时间</td><td width="160px">备注</td>
              </tr>
            </thead>
            <% 
               CmReimbursementDetailEntry crd= null;
               while(qr.hasNext()){
            	   crd = (CmReimbursementDetailEntry)qr.next();
            %>
              <tr>
                <td><%=crd.getCmDetailType() %></td>
                <td><%=crd.getCmDetailAmount() %></td>
                <td><%=crd.getCmDetailTo() %></td>
                <td><%=sdf.format(crd.getCmDetailTime()) %></td>
                <td><%=crd.getCmDetailDesc() %></td>
              </tr>
            <% }%>
              <tr>
                <td>&nbsp;</td><td></td><td></td><td></td><td></td>
              </tr>
              <tr>
                <td>&nbsp;</td><td></td><td></td><td></td><td></td>
              </tr>
              <tr>
                <td>&nbsp;</td><td></td><td></td><td></td><td></td>
              </tr>
         </table> 
      </td>
      </tr>
      <!-- 签审信息距离处理 -->
      <tr>
        <td></td>
      </tr>
      <!-- 报销单签名 -->
      <tr>
      <td>
          <table width="100%">
            <tr>
        <%if("公共费用".equals(rbType)){%> 
              <td width="33%" align="left">
                <div>审核者：<%=TpWorkflowHelper.getSignInfo(signInfos, "审核者", "fullName", null) %></div>
                <div><font color="#FFFFFF">审核者：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "审核者", "copleteTime", sdf) %></div>
              </td>
              <td width="33%" align="left">
                <div>批准者：<%=TpWorkflowHelper.getSignInfo(signInfos, "批准者", "fullName", null) %></div>
                <div><font color="#FFFFFF">批准者：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "批准者", "copleteTime", sdf) %></div>
              </td>
              <td width="33%" align="left">
                <div>财务：<%=TpWorkflowHelper.getSignInfo(signInfos, "财务", "fullName", null) %></div>
                <div><font color="#FFFFFF">财务：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "财务", "copleteTime", sdf) %></div>
              </td>
        <%}else{%> 
              <td width="25%">
                <div>项目经理：<%=TpWorkflowHelper.getSignInfo(signInfos, "项目经理", "fullName", null) %></div>
                <div><font color="#FFFFFF">项目经理：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "项目经理", "copleteTime", sdf) %></div>
              </td>
              <td width="25%">
                <div>审核者：<%=TpWorkflowHelper.getSignInfo(signInfos, "审核者", "fullName", null) %></div>
                <div><font color="#FFFFFF">审核者：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "审核者", "copleteTime", sdf) %></div>
              </td>
              <td width="25%">
                <div>批准者：<%=TpWorkflowHelper.getSignInfo(signInfos, "批准者", "fullName", null) %></div>
                <div><font color="#FFFFFF">批准者：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "批准者", "copleteTime", sdf) %></div>
              </td>
              <td width="25%">
                <div>财务：<%=TpWorkflowHelper.getSignInfo(signInfos, "财务", "fullName", null) %></div>
                <div><font color="#FFFFFF">财务：</font><%=TpWorkflowHelper.getSignInfo(signInfos, "财务", "copleteTime", sdf) %></div>
              </td>
        <%} %>
            </tr>
          </table>
      </td>
      </tr>
   </table>
</div>
</div>
</body>
</html>